﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aima.NET.Test.Core.Logic.Propositional.Algorithms
{
    using Aima.Core.Logic.Propositional.Algorithms;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class WalkSATTest 
    {

        [TestMethod]
        //TODO: figure out how to pass multiple input values to be tested
        public void FindModelForAAndB() 
        {
            var walkSAT = new WalkSAT();
            var m = walkSAT.FindModelFor("( A AND B )", 1000, 0.5);
            Assert.IsNotNull(m, "Failed to find model");
        }

        [TestMethod]
        public void FindModelForAAndNotB() 
        {
            var walkSAT = new WalkSAT();
            var m = walkSAT.FindModelFor("( A AND (NOT B) )", 1000, 0.5);
            Assert.IsNotNull(m, "Failed to find model");
        }

        [TestMethod]
        public void FindModelForKnowledgeBaseSentence() 
        {
            KnowledgeBase kb = new KnowledgeBase();
            kb.Tell(" (P => Q)");
            kb.Tell("((L AND M) => P)");
            kb.Tell("((B AND L) => M)");
            kb.Tell("( (A AND P) => L)");
            kb.Tell("((A AND B) => L)");
            kb.Tell("(A)");
            kb.Tell("(B)");
            WalkSAT walkSAT = new WalkSAT();
            Model m = walkSAT.FindModelFor(kb.AsSentence().ToString(), 1000, 0.5);
            Assert.IsNotNull(m, "Failed to find model");
        }
    }

}
